package com.Dec_Forteen;

public class Solution55 {

    public boolean canJump(int[] nums) {
        int n=nums.length;
        if (n==1) return true;
        int cover=0;
        for (int i = 0; i <= cover; i++) {
            cover=Math.max(cover,i+nums[i]);
            if (cover>=n-1) return true;
        }
        return false;
    }

    public static void main(String[] args) {
        Solution55 solution55=new Solution55();
        System.out.println(solution55.canJump(new int[]{2,3,1,1,4}));
    }
}
